import 'package:flutter/material.dart';
import 'AddressList.dart';

class GetAddress extends StatefulWidget {
  @override
  _GetAddressState createState() => _GetAddressState();
}

class _GetAddressState extends State<GetAddress> {
  String _address = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('getAddress'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              child: Text("跳转我的收货地址"),
              // onPressed: () async {
              //   String data = await Navigator.of(context).push(MaterialPageRoute(
              //     builder: (BuildContext context){
              //       return AddressList();
              //     }
              //   ));

              //   setState(() {
              //    _address = data;
              //   });
              // },
              onPressed: () {
                Navigator.of(context)
                    .push(MaterialPageRoute(builder: (BuildContext context) {
                  return AddressList();
                })).then((value) {
                  setState(() {
                    _address = value;
                  });
                });
              },
            ),
            Text('${_address == "" ? "未发现收货地址" : _address}')
          ],
        ),
      ),
    );
  }
}
